package code.c06;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/10/13 10:11
 * @package code.c06
 * @description 文件说明
 */

public interface Shape {
    public abstract double getPerimeter();

    public abstract double getArea();
}

class Rectangle implements Shape {

    int weight;
    int height;

    public Rectangle(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }

    public Rectangle() {
    }

    @Override
    public double getPerimeter() {
        return 2 * (weight + height);
    }

    @Override
    public double getArea() {
        return weight * height;
    }
}

class Circle implements Shape {
    private int r;
    private final double PI = Math.PI;

    public Circle(int r) {
        this.r = r;
    }

    public Circle() {
    }

    @Override
    public double getPerimeter() {
        return 2 * PI * r;
    }

    @Override
    public double getArea() {
        return PI * r * r;
    }
}

class DrawShape{
    public void draw(Shape shape){
        System.out.println(shape.getArea());

        System.out.println(shape.getPerimeter());
    }
}

class TestShape{
    public static void main(String[] args) {
        DrawShape drawShape = new DrawShape();

        Circle circle = new Circle(5);
        Rectangle rectangle = new Rectangle(3,5);

        drawShape.draw(circle);
        drawShape.draw(rectangle);
    }
}
